package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.vec2.Vector2

/**
 * atan2 style angle between this and [other]
 */
fun<T:Number> Vector2<T, *>.atan2(other: Vector2<T, *>) : T {
    val u = this.normalized as Vector2<T, *>
    val v = other.normalized as Vector2<T, *>
    val x = u dot v
    val y = sqrt(1.0 - x * x)
    return atan2(y, x)
}